using UnityEngine;
using System.Collections;

public class Movements : MonoBehaviour {
	
	
	public float speed = 6.0F;
    public float jumpSpeed = 8.0F;
    public float gravity = 20.0F;
    private Vector3 moveDirection = Vector3.zero;
    
	void Start () {
	
	}
	
	void Update () {
		
		
		
		// Tratar condicional para a plataforma Android ou com o acelerometro
		
		#if UNITY_IPHONE || UNITY_ANDROID
		
		Vector3 dir = Vector3.zero;
		
		dir.x = -Input.acceleration.y;
		dir.z = Input.acceleration.x;
		
		if(dir.sqrMagnitude > 1){
			dir.Normalize();
		}
		
		dir *= Time.deltaTime;
		
		transform.Translate(dir * speed);
		
		#elif !UNITY_FLASH
		
		CharacterController controller = GetComponent<CharacterController>();
        
		moveDirection = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
        //moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed;
            
        controller.Move(moveDirection * Time.deltaTime);
		
		#endif

    
	}
	
}
